const mysql = require('../lib/MysqlCalss')

exports.article_list = async (ctx, next) => {
  const params = 'select * from blog_list ' // where DATEDIFF(now(),modified)=1
  console.log(params)
  await mysql.query(params).then(res => {
    ctx.originData = res
    ctx.status = 200
  }).catch(err => {
    console.log(err)
  })
  await next()
}

exports.article_add = async (ctx, next) => {
  console.log('---------')
  const body = ctx.request.body
  console.log(body)
  const params = 'insert blog_list(article_name,article_content,article_type,tmp) values("' + body.article_name + '","' + body.article_content + '","' + body.article_type + '","' + body.tmp + '")'
  console.log(params)
  await mysql.query(params).then(res => {
    ctx.originData = '写入成功'
    ctx.status = 200
  }).catch(err => {
    console.log(err)
  })
  await next()
}
